home *** CD-ROM | disk | FTP | other *** search
-
-
-
- TheMouse For Turbo Pascal!
- Units for Turbo Pascal 4 and 5
-
-
-
- Kevin A. Kwast
- P.O. Box 1397
- Coppell, Texas
- 75019
-
-
- $10 Shareware Registration
-
-
-
- DOCUMENTATION
-
-
-
-
-
-
-
- TheMouse is a collection of routines for accessing a Microsoft or
- compatible mouse from Turbo Pascal. You can now easily include mouse
- support to your programs with these 12 simple routines, which access the
- 14 most common functions provided by interrupt 33h.
-
- Requirements: Turbo Pascal 4.0 or higher.
-
- All of the routines are in a unit, which must be included in your program's
- USES statement to make the procedures available to your program. For detailed
- information on units, see your Turbo Pascal manual.
-
- Users of Turbo Pascal 4 or 5.0 should use the TMOUSE4 unit, and users of
- version 5.5 should use TMOUSE5. The source code in these units is IDENTICAL,
- except that version 4 and 5.0 units are not compatible with version 5.5, and
- vice versa.
-
- For example:
-
- Uses Crt, Dos, TMouse4;
-
-
- Most of these routines work identically whether you are in text or in
- graphics mode, but the coordinate system does differ. In text mode, the
- screen's resolution is 640x200 (the same as CGA's high resolution). To
- determine the text cursor position, divide the location by 8.
-
- In graphics mode, the screen's resolution is determined by what graphics
- mode and driver you are in.
-
-
- This is the Interface section of the units:
-
- Type TheMouseInitType = Record
- Exists: Boolean;
- Buttons: Integer;
- { Bit 0: Left Button }
- { Bit 1: Right Button }
- { Bit 2: Middle Button, if present }
- End;
-
- TheMouseInfoType = Record
- ButtonStatus,
- ButtonCount,
- Column,
- Row: Integer;
- End;
-
- TheMouseEventType = Record {For Event Trapping}
- EventMask,
- ButtonStatus,
- Column,
- Row: Word;
- End;
-
-
- Var TheMouseCursorStatus: Integer;
-
- Procedure tmReset(var TheMouseInit: TheMouseInitType);
- Procedure tmCursor(Show: Boolean);
- Procedure tmPos(var TheMouseInfo: TheMouseInfoType);
- Procedure tmMoveTo(Col, Row: Integer);
- Procedure tmPressed(Button: Integer; var TheMouseInfo: TheMouseInfoType);
- Procedure tmReleased(Button: Integer; var TheMouseInfo: TheMouseInfoType);
- Procedure tmColRange(Min, Max: Integer);
- Procedure tmRowRange(Min, Max: Integer);
- Procedure tmGraphCursor(HHot, VHot: Integer; MaskSeg, MaskOfs: Word);
- Procedure tmTextCursor(CursorType, Arg1, Arg2: Word);
- Procedure tmTask(Mask, TaskSeg, TaskOfs: Word);
- Procedure tmPen(Pen: Boolean);
-
-
- Here are detailed descriptions of the three types, one variable, and ten
- procedures available in the units:
-
-
- Type TheMouseInitType Used By: tmReset
-
- This type returns information about the mouse, such as whether one is
- available, and how many buttons it has.
-
- Type TheMouseInfoType Used By: tmPos, tmPressed, tmRelease
-
- This type returns information about the mouse and the buttons on
- the mouse.
-
- Type TheMouseEventType Not Used by Any of the Routines
-
- This type is not used by the routines in TheMouse. It has been provided
- for your convenience in writing event handlers for tmTask. See the
- example event handler in MouseMenu for more information.
-
- Var TheMouseCursorStatus: Integer
-
- The mouse routines update this variable, since there is no way to
- ask the mouse driver whether the mouse cursor is turned on or off.
- When you use tmReset, this variable is set to -1 (cursor off). When
- you use tmCursor to turn the cursor on, it sets TheMouseCursorStatus
- to zero. When you use tmCursor(False) to turn the mouse cursor off,
- TheMouseCursorStatus is set back to -1. Thus, you can check this
- variable, and if TheMouseCursorStatus is zero, the cursor is on. If
- TheMouseCursorStatus is -1, then the cursor is off. This is the
- method used internally by the Mouse Driver, except that the Mouse
- Driver allows you to sink into several layers of cursor off, requiring
- you to use "cursor on" several times to turn the cursor back on. This
- unit is intelligent enough to keep that from happening, so you can
- be assured that when you say tmCursor(True), the cursor really is
- on. DO NOT CHANGE THIS VARIABLE YOURSELF!
-
-
- Procedure tmReset(var TheMouseInitType); Function 0
-
- Use tmReset at the beginning and the end of your program. This will
- initialize the mouse, place the mouse cursor in the center of the
- screen, turn the mouse cursor off, and set the mouse's range to the
- full screen. This procedure returns the existence of a mouse, and the
- number of buttons.
-
- Exists: Boolean TRUE is a mouse is installed, FALSE otherwise
- Buttons: Integer The number of buttons on the mouse (2 or 3)
-
-
- Procedure tmCursor(Cursor: Boolean); Functions 1 and 2
-
- If you specify tmCursor(True), the mouse cursor is turned on. If you
- specify tmCursor(False), the mouse cursor is turned off. The status
- variable (TheMouseCursorStatus) is always adjusted accordingly.
- When the cursor is in text mode, it stores the character at the
- position the cursor is on. When the cursor leaves that position, or
- is turned off, the original character and attribute are restored. This
- makes a lot of sense, but it can cause one problem. If you write
- something at the mouse cursor's current location, it is replaced by
- the mouse driver when the cursor leaves that spot. If this is hard
- to understand, see the DoDemo procedure in the MouseText example.
-
-
- Procedure tmPos(var M: TheMouseInfoType); Function 3
-
- This procedure returns information about the current status of the
- mouse. It returns the current location of the mouse, and the
- status of the mouse buttons. This function is not as useful as some
- of the others, because it requires that you check it constantly.
- See the example mouse graphics program, MouseDraw, for an example of
- the function in use.
-
- ButtonStatus: Returns which buttons are currently pressed
- Column: The Column Location (X) of the Mouse
- Row: The Row Location (Y) of the Mouse
-
-
- Procedure tmMoveTo(Column, Row: Integer); Function 4
-
- This procedure moves the mouse cursor to a specified position.
-
-
- Procedure tmPressed(B: Integer; var M: TheMouseInfoType); Function 5
-
- This procedure returns information about how many times the button
- specified in B (0 = left; 1 = right; 2 = middle) has been pressed.
- Getting this information clears it from the mouse device driver, so
- this procedure returns information about what has happened since the
- last call to tmPressed. One warning about using tmPressed: If it is
- checked in a loop, the loop might check the procedure several times
- while the button is held down, but each check would return that same
- click as if it were a new one.
-
- ButtonStatus: The current status of the buttons, as in tmPos.
- ButtonCount: The number of times button B has been pressed.
- Column, Row: The position of the mouse THE LAST TIME BUTTON B WAS
- PRESSED. If it is currently pressed, the current
- position is returned.
-
-
- Procedure tmReleased(B: Integer; var M: TheMouseInfoType); Function 6
-
- This procedure returns information about how many times the button
- specified in B (0 = left; 1 = right; 2 = middle) has been released.
- Similar to tmPressed, calling this procedure clears the information
- from the mouse device driver, so information is relative to the last
- call to tmReleased. This is a better way to check the mouse than
- tmPressed, since a button being released only happens once each click.
-
- ButtonStatus: The current status of the buttons, as in tmPos.
- ButtonCount: The number of times button B has been released.
- Column, Row: The position of the mouse the last time button B
- was released.
-
-
- Procedure tmColRange(Min, Max: Integer); Function 7
-
- This procedure sets the columns in which the mouse cursor can travel.
- The mouse cursor will refuse to leave the area you confine it to.
-
- Procedure tmRowRange(Min, Max: Integer); Function 8
-
- Similar to tmColRange, this procedure sets the rows for the cursor.
- See the example program, MouseMenu, for an example of how this can
- be very useful.
-
-
- Procedure tmGraphCursor(hHot, vHot: Integer; maskSeg, maskOfs: Word);
- Function 9
-
- This sets the graphics cursor from the default northwest-pointing
- arrow to any cursor you want. Please see the example graphics program,
- MouseDraw, for information and routines pertaining to the graphics
- cursor.
-
-
- Procedure tmTextCursor(CursorType, Arg1, Arg2: word); Function 10
-
- There are two types of cursors in text mode, the video adapter's cursor
- (a "hardware" cursor) and the mouse driver's cursor. CursorType 1 puts
- the hardware cursor under your control, although the location for the
- text I/O does not change. CursorType 0 creates a seperate mouse cursor,
- leaving the hardware cursor to act normally. In addition, the mouse
- driver's cursor can be customized, making it appear like any of the
- 256 IBM ASCII characters. The mouse driver cursor (type 0) is the
- default, and it's appearance defaults to a full block (ASCII 219) that
- inverts the attribute of the character it is on. Also, unlike the
- hardware cursor, the mouse driver's cursor does not blink.
-
- Arg1 and Arg2 control the appearance of the cursor.
- -- Arg1 is the screen mask. Use $77FF for the see-through
- rectangle and 0 for one of the IBM ASCII characters.
- -- Arg2 defines the cursor itself. Put the attribute byte for
- the cursor in the upper byte of the word, and place the ASCII
- value for the character in the lower byte. Use 0 for the
- rectangle.
-
- The hardware cursor's appearance can be modified somewhat. Use
- Arg1 to define the top scan line (which is always 0), and put the
- bottom scan line in Arg2. (On monochrome systems, the bottom scan
- line is 12. On systems with graphics boards [CGA,EGA,etc.] operating
- in text mode, the bottom scan line is 7)
-
-
- Procedure tmTask(Mask, TaskSeg, TaskOfs: Word); Function 12
-
- This is one of the most powerful procedures in TheMouse. It keeps you
- from having to constantly scan the mouse in much the same way the ringer
- on a telephone keeps you from having to keep picking up the phone to see
- if anyone is there. tmTask attaches one of your routines (a task) to
- the mouse driver, so that your routine is automatically called when
- certain mouse events take place. Just be sure that your procedure is
- declared as a far call, and pass its address to tmTask, along with a
- mask telling it what events to branch on. Please see the example
- mouse event handler in MouseMenu for other information.
-
- The mask is made up of these bits:
-
- Bit 0 Movement
- Bit 1 Left Button Press
- Bit 2 Left Button Release
- Bit 3 Right Button Press
- Bit 4 Right Button Release
- Bit 5 Middle Button Press
- Bit 6 Middle Button Release
-
- The data returned from the mouse event handler is as follows:
-
- Register AX -- The event that occured (in a bit set)
- Register BX -- Current button status (as in tmPos)
- Register CX -- Column Position
- Register DX -- Row Position
-
-
- Procedure tmPen(Pen: Boolean); Function 13 and 14
-
- You may never have a use for this routine, but it has been provided for
- you. When you reset the mouse, light pen emulation is set to ON by
- default. When light pen emulation is on, the mouse cursor's position is
- taken as the light pen's position. If your program uses a light pen for
- input, be sure you use tmPen(False) to turn the mouse driver's light pen
- emulation off.
-
-
- See the two example Turbo Pascal programs, MouseDraw and MouseText, for
- detailed information and example programs involving the routines in
- TheMouse. MouseDraw demonstrates the mouse routines in a graphics drawing
- program (CGA required), and MouseText uses the routines in text mode.
-
-
- If you make use of the routines in TheMouse, please register. You have 30
- days to examine TheMouse, and if you are satisfied with it, then please
- send $10 to me at the address on the first page of documentation. To thank
- you for your registration, I'll send you the TheMouse Icon Editor which you
- can use to create icons for use with TheMouse. If you'd like the source
- code to TheMouse and the Icon Editor, then please send an additional $25.
-
- I hope you enjoy and make use of these routines!
-
-
- ..Kevin Kwast
-
-
- ----------------end-of-author's-documentation---------------
-
- Software Library Information:
-
- This disk copy provided as a service of
-
- Public (software) Library
-
- We are not the authors of this program, nor are we associated
- with the author in any way other than as a distributor of the
- program in accordance with the author's terms of distribution.
-
- Please direct shareware payments and specific questions about
- this program to the author of the program, whose name appears
- elsewhere in this documentation. If you have trouble getting
- in touch with the author, we will do whatever we can to help
- you with your questions. All programs have been tested and do
- run. To report problems, please use the form that is in the
- file PROBLEM.DOC on many of our disks or in other written for-
- mat with screen printouts, if possible. PsL cannot debug pro-
- programs over the telephone, though we can answer questions.
-
- Disks in the PsL are updated monthly, so if you did not get
- this disk directly from the PsL, you should be aware that the
- files in this set may no longer be the current versions. Also,
- if you got this disk from another vendor and are having prob-
- lems, be aware that some files may have become corrupted or
- lost by that vendor. Get a current, working disk from PsL.
-
- For a copy of the latest monthly software library newsletter
- and a list of the 3,000+ disks in the library, call or write
-
- Public (software) Library
- P.O.Box 35705 - F
- Houston, TX 77235-5705
-
- 1-800-2424-PSL
- MC/Visa/AmEx/Discover
-
- Outside of U.S. or in Texas
- or for general information,
- Call 1-713-524-6394
-
- PsL also has an outstanding
- catalog for the Macintosh.
-